package com.ktjy.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ktjy.entity.SysUser;
import com.ktjy.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    RedisTemplate redisTemplate;

    @Autowired
    ISysUserService userService;


    @RequestMapping("/list")
    @PreAuthorize("hasAuthority('L0601')")
    public Object pageList(@RequestParam(defaultValue = "1") Integer pageIndex,
                           @RequestParam(defaultValue = "10") Integer pageSize,
                           @RequestParam(required = false) SysUser user) throws InterruptedException {
        IPage<SysUser> page = new Page<>(pageIndex, pageSize);
//        System.out.println(  ( (SysUser) redisTemplate.opsForValue().get("sysUser")).getUsrName());
        return userService.page(page, user);
    }


}
